package cn.zooz.common.util.kit;

import java.nio.ByteBuffer;

/**
 * Created by Bradish7Y on 2017/8/14.
 */
public final class ByteUtils {
    private ByteUtils() {

    }

    /**
     * int to byte
     *
     * @param value
     * @return
     */
    public static byte[] toBytes(int value) {
        byte[] bytes = new byte[4];
        ByteBuffer.wrap(bytes).putInt(value);
        return bytes;
    }

    public static int fromBytes(byte[] bytes) {
        return ByteBuffer.wrap(bytes).getInt();
    }
}
